<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <h2>JS作用域</h2>
</body>
<script>
     console.log('1:',str)
    var str='hello'
    console.log('2:',str)

    function getName() {
        //局部作用域
        str='vue';
        console.log('3:',str)
       const getName2=function() {
        str='小程序';
        console.log('4:',str)
       } 

       getName2()
       console.log('5:',str)
    }

    getName()
    console.log('6:',str)

   

</script>
</html>